Note: the information presented here is preliminary. In particular, the exact values for the color table initialization may change.
16-Color Extension
This extension defines an expanded 16-color model, primarily for use by Client Programs. The model supports what has been described as ANSI-graphics, PC-ANSI graphics, etc. The extension requires the presence of two features. The first is that the Open Firmware implementation has to have a version of the Terminal Emulator that supports the expanded escape sequences. This is indicated (for use by Client Programs) by the presence of a new property ("iso6429-1983-colors") in a new /packages/terminal-emulator node. The second requirement is that the "display" driver have support for the CLUT setup required by the Terminal Emulator. This is indicated by having the "display" driver publish the "iso6429-1983-colors" property. The Open Firmware Terminal Emulator will initialize the values of its foreground and background color values to their appropriate values, depending upon the presence of this property in the "display" package.
Note: see the discussion in Color Table (CLUT) Initialization for what has to be done by a "display" driver to detect the presence of the support of the Terminal Emulator, and the implications for how the driver has to initialize its CLUT.
IEEE Std 1275-1994 defines the behavior of the Terminal Emulator Support Package (see Annex B of [1]). Annex B of [1] assumes that the Terminal Emulator Support Package implements certain escape sequences from the set defined by ANSI X3.64. The extension described here corresponds to ISO 6429-1983, as defined by [2]. An implementation of Open Firmware for PowerPC is required to support additional graphic renditions (via the SGR - Select Graphic Rendition - ESC[#m) beyond those specified in Annex B.
In order for these extensions to be used, the FCode device driver for a display device (i.e., a device whose "device_type" property has the value "display") shall initialize the first 16 entries of its color table to appropriate values (see Color Table Initialization). These values assume that the color is represented by the low-order 3 bits of the color index and that the bit corresponding to a value of 8 represents the intensity. The ISO 6429-1983 standard provides parameter values to independently control the color of foreground (30-37) and background (40-47). The intensity is set separately (1-2), and must be issued before the color control; 1 -> color, 2 -> color+8.
The expanded model of the Terminal Emulator is that there is a "current" background and foreground color (index), each of whose value is 0-15, corresponding to the first 16 entries of the color table. In positive image mode, pixels corresponding to a font (logo) bit set (1) shall be set to the foreground color; pixels corresponding to a font (logo) bit clear (0) shall be set to the background color. When in negative image mode, the roles of foreground and background are reversed.
The default rendition shall be positive image mode, background=15 and foreground=0, thus producing black characters on a bright white background.
The following table describes the effect of executing the SGR escape sequence with the specified parameter.
Param Interpretation
0 default rendition
1 bold (increased intensity)
2 faint (decreased intensity)
7 negative image
27 positive image
30 black foreground
31 red foreground
32 green foreground
33 yellow foreground
34 blue foreground
35 magenta foreground
36 cyan foreground
37 white foreground
40 black background
41 red background
42 green background
43 yellow background
44 blue background
45 magenta background
46 cyan background
47 white background
Table 1. SGR Parameters
Display devices
This section defines additional behavior of display devices (e.g., device_type = "display") for Open Firmware implementations that support the Terminal Emulator Extensions.
Color Table (CLUT) Initialization
The core specification of Open Firmware defines a Terminal Emulation Support Package that, while defined for 8-bit pixels, does not include support for colors. In order to support the Terminal Emulator Extensions, Open Firmware implementations will support additional Select Graphic Rendition parameters in order to allow client programs to display characters (and logos) using a 16-color model.
CLUT Initialization for older Open Firmware implementations
Not every Open Firmware will support the extensions. For use in those systems, the "display" FCode driver has to initializat the CLU in a manner consisten with the original 1275 model. That model assumed that the 8-bit pixel values for ForeGround and that BackGround are 0xFF and 0x00, respectively. Note that the interpretation of the value 0 is exactly opposite! Therefore, the FCode driver must detect if the Open Firmware is using the new 16-color extensions, or not.
The following code snippet does that:
h# 168 get-token drop ['] ferror <> if
\ initialize for the new 16-color CLUT model
else
\ intialize for the original 1275 interpretation
then
The code above works by detecting whether non-error code exists for the new FCode assigned to foreground-color.
CLUT Initialization for the 16-color extensions
For the expanded Terminal Emulation support to work, Open Firmware device drivers for "display" devices shall initialize the first 16 entries of their color table to values defined in Table 2.Color Table Values. Note that the table values are defined in terms of percentage of full saturation color for each of the primary RGB colors.
Index Red Green Blue Color
0 0 0 0 Black
1 0 0 2/3 Blue
2 0 2/3 0 Green
3 0 2/3 2/3 Cyan
4 2/3 0 0 Red
5 2/3 0 2/3 Magenta
6 2/3 1/3 0 Brown
7 2/3 2/3 2/3 White
8 1/3 1/3 1/3 Gray
9 1/3 1/3 1 Light Blue
10 1/3 1 1/3 Light Green
11 1/3 1 1 Light Cyan
12 1 1/3 1/3 Light Red
13 1 1/3 1 Light Magenta
14 1 1 1/3 Yellow
15 1 1 1 Bright White
Table 4. Color Table Values
"display" device standard properties
In addition to the standard properties defined by Open Firmware for display devices, the following properties shall be present.
"iso6429-1983-colors"
Standard property, with a null prop-encoded array, that indicates that the the device driver supports the
additional methods required for this extension.
"width"
Standard property, encoded as with encode-int, that represents the visible width of the display in pixels.
"height"
Standard property, encoded as with encode-int, that represents the visible height of the display in pixels.
"linebytes"
Standard property, encoded as with encode-int, that represents the address offset between a pixel on one
scan line and that same relative horizontal pixel position on the immediately following scan line.
"depth"
Standard property, encoded as with encode-int, that represents the number of bits in each pixel.
Graphics Extension
Another, somewhat independent, extension that has been defined is a so-called "graphics" extension. This extension assumes that a "display" driver supports a full 8-bit pixel format, including a CLUT that can represent 256 colors. The first 16 colors are defined by the 16-color Extension described above. This extension adds support for more colors and for a limited "graphics" capability.
The color support is designed to let Client Programs have control of the color-space by providing access to the CLUT by a set of new methods (set-colors, get-colors, color!, color@), defined below.
The graphics support defines methods (draw-rectangle, read-rectangle, fill-rectangle) that allow a Client Program to read and write rectangular areas of the display buffer.
"display" device standard methods
This section defines additional methods that "display" devices should implement in order to be compliant with the Graphics Extensions. These methods assume that the device supports at least 16 colors using the R-G-B color model, and that a Color Lookup Table (CLUT) exists that can be read and written. The model assumes 8-bit values for each of the R-G-B components of the colors, where 0x00 implies no color and 0xFF is full saturation of the component. If fewer bits are available, the corresponding entries should be scaled appropriately.
Individual color entries are specified by their R-G-B values, using 8 bits for each. Each color is represented by an "index".
Note: The index values for the 16-color Extension are in the range 0..15; however, most display hardware will support at least 256 colors.
The following methods allow access to the CLUT from Client Programs (and, the User Interface):
set-colors ( adr index #indices -- )
This method allows the setting of a number of consecutive colors, starting at the index color,
for #indices colors. adr is the address of a table of packed R-G-B components.
get-colors ( adr index #indices -- )
This method allows the reading of a number of consecutive colors, starting at the index color,
for #indices colors. adr is the address of a table that will be filled in with packed R-G-B
components.
color! ( r g b index -- )
This method allows the setting of a single color value, specified by index. r, g and b are
the values to be placed into the Red, Green and Blue components, respectively.
color@ ( index -- r g b )
This method allows the reading of the color components of a single color value, specified
by index. r, g and b are the values of the Red, Green and Blue components, respectively.
The following methods support a minimal "bit-mapped" graphics capabilities for Client programs:
draw-rectangle ( adr x y w h -- )
This method copies a pixel-map (consisting of consecutive bytes of index values) to the screen.
The x,y parameters specify the horizontal and vertical location of the top-left corner of the rectangle;
0,0 represents the top-left pixel of the screen. The width and height of the source rectangle are given
by the w,h parameters. The pixel map is specified by the adr argument and consists of an array of
index values of size w*h.
fill-rectangle ( index x y w h -- )
This method fills a screen rectangle, whose top-left is specified by x,y and whose size is specified by
w,h, with a constant index value specified by index.
read-rectangle ( adr x y w h -- )
This method is the inverse of draw-rectangle. I.e., it copies a screen bit-map, whose location and
size are specified by x,y and w,h, to the memory location specified by adr.
References
[1] IEEE Std 1275-1994 Standard for Boot (Initialization Configuration) Firmware, Core Practices and Requirements, published by IEEE.
[2] ISO 6429, Information processing -- ISO 7-bit and 8-bit coded character sets -- Additional control functions for character-imaging devices, published by International Organization for Standardization.